package org.seler.spring.data.jdbc;

import java.util.List;

import org.seler.spring.data.jdbc.pojo.WorkOrdInfoDO;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test_JDBC {

	/**
	 * @param args
	 * @throws InterruptedException 
	 */
	public static void main(String[] args) throws InterruptedException {

		ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"org/seler/configuration/beans.xml"});
//		WorkOrderDao workDao = (WorkOrderDao)context.getBean("workOrderDao");
//		WorkOrdInfoDO workInfoDo = workDao.retrieveWorkOrderByWorkOrderNo("BBC5574001");
//		String svcInstId = workInfoDo.getSvcInstId();
//		System.out.println(svcInstId);
//		List<WorkOrdInfoDO> list = workDao.retrievieWorkOrder(100);
//		for(WorkOrdInfoDO workDo:list){
//			System.out.println("workNo: " + workDo.getWorkOrdNo()+ "\t" + "svcInstId: " + workDo.getSvcInstId());
//		}
		int count = 0;
		while(count < 10) {
			count ++;
			new JDBCThread(context).run();
		}
	}

	
	 static class JDBCThread extends Thread {
		 
		ApplicationContext context;
		
		private String threadName;
		
		public  JDBCThread() {}
		
		public  JDBCThread(ApplicationContext context) {
			this.context = context;
		}
		
		public  JDBCThread(String threadName) {
			this.threadName = threadName;
		}
		
		public void run() {
			WorkOrderDao workDao = (WorkOrderDao)context.getBean("workOrderDao");
			List<WorkOrdInfoDO> list = workDao.retrievieWorkOrder(10);
			for(WorkOrdInfoDO workDo:list){
				System.out.println("workNo: " + workDo.getWorkOrdNo()+ "\t" + "svcInstId: " + workDo.getSvcInstId());
			}
			
		}
		 
	 }

}

